package com.zm.xdata.service.publics.poster.controller.api;

import com.zm.xdata.service.publics.poster.model.SysHaibao;
import com.zm.xdata.service.publics.poster.service.ISysHaibaoService;
import com.zm.xdata.service.publics.poster.model.base.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Slf4j
@Api("全局参数接口")

@RestController
@RequestMapping(value = "/api/admin/global")
public class ApiController {

    @Autowired
    private ISysHaibaoService sysHaibaoService;

    @ApiOperation(value="上传接口",notes = "用于上传")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称",  required = true,dataType = "string", paramType = "query")})
    @PostMapping("/upload")
    public ApiResult<String> upload(@RequestParam(name = "name") String name,
                                    @RequestParam(value = "touxiang") MultipartFile touxiang,
                                    @RequestParam(value = "beijing") MultipartFile beijing)  {
        ApiResult<String> result=new ApiResult<>();
        sysHaibaoService.upload(name,touxiang,beijing);
        return result.success("上传成功");
    }

    @ApiOperation(value="查询所有海报",notes = "查询所有海报")
    @PostMapping("/query")
    public ApiResult<List<SysHaibao>> query() {
        ApiResult<List<SysHaibao>> result=new ApiResult<>();
        return result.success(sysHaibaoService.list());
    }


}
